package ee.ut.maxorato_macobo.oop.mud.items;

import java.util.Scanner;

import ee.ut.maxorato_macobo.oop.mud.game.DataParser;
import ee.ut.maxorato_macobo.oop.mud.game.GameUtils;

public class ItemFoodTemplate extends ItemTemplate {
	private int restoreEnergy;
	
	public ItemFoodTemplate(String newUniqueName, String newItemName, String newItemLongName, String newItemDescription) {
		super(newUniqueName, newItemName, newItemLongName, newItemDescription);
		
		restoreEnergy = 0;
	}
	
	@Override
	public Class<? extends ItemBase> getItemClass() {
		return ItemFood.class;
	}
	
	public String getItemType() {
		return "food";
	}
	
	public void parseExtraSection(Scanner parser) {
		while(parser.hasNextLine()) {
			String[] parts = parser.nextLine().trim().split(" ", 2);
			
			if(parts[0].equals("energy")) {
				restoreEnergy = GameUtils.properIntParser(parts[1]);
			}
			else if(parts[0].equals("sub")) {
				DataParser.parseDummy(parser);
			}
			else if(parts[0].equals("end")) {
				break;
			}
		}
	}
	
	public int getRestoreEnergy() {
		return restoreEnergy;
	}
}
